function config(){
	$(".ajaxlistcreator .ajaxpost").live('click', function(e){
		e.preventDefault();
		parent = $(this).closest('.ajaxlistcreator');
		$.ajax({
                	type: "GET",
                        url: $(this).attr("href"),
                        data: "query=" + parent.find('input[type=text]').val(),
                        success: function(msg){
				parent.find('.negativeresponse').html('').addClass('hidden');
				parent.find('input[type=text]').val('');
				arr = msg.split(',');
				if(arr.length == 1) {
					parent.find('.negativeresponse').html(msg).removeClass('hidden');
					return;
				}
				id = arr[0];
				name = arr[1];
					
				prevval = parent.find('.ajaxhiddenlist').val();
				arr = prevval.split(',');
				for(aid in arr){
					if(arr[aid] == id) return;
				}

				if(prevval == '')
					newval = id;
				else
					newval = prevval + "," + id;
				parent.find('.ajaxhiddenlist').val(newval);
				prevhtml = parent.find('.ajaxlist').html();
				newhtml = prevhtml + "<a href='/user/?uid=" + id + "'>" + name + "</a>";
				parent.find('.ajaxlist').html(newhtml);
			},
                        error: function(msg){
				parent.find('input[type=text]').val('');
                        	parent.find('.negativeresponse').html('User not found').removeClass('hidden');
			}
                });		
	});

	$(".dialogopener").live("click", function(e){
		e.preventDefault();
		openDialog($(this).attr("href"), $(this).attr("title"));
	});

}

function openDialog(url, title){
        $.ajax({
                type: "GET",
                url: url,
                success: function(msg){
                        if(msg != "failure"){
                                html = msg;
                        }
                        else{
                                html = "<h3 class='ui-state-error ui-corner-all highlight' align='center' style='width:80%;margin-left:10%;'>OOPS..Something went wrong. Please try again.</h3>"
                        }
                        if($("#dialog").dialog("isOpen")) $("#dialog").dialog("close");
                        $("#dialog .dialogcontent").html(html);

                        $("#dialog").dialog({
                                title:title,
                                modal:false,
                                width:"auto",
                                height:"auto",
                                show:'fade',
                                buttons:{},
                                autoOpen:false,
                                //hide:'fade',
                                open: function(event, ui) {
                                        //$(this).css({'max-height': 400, 'overflow-y': 'auto'});
                                }
                        });
                        $("#dialog").dialog('open');
                },
		error: function(msg){
                        html = "<h3 class='ui-state-error ui-corner-all highlight' align='center' style='width:80%;margin-left:10%;'>OOPS..Something went wrong. Please try again.</h3>"
                        if($("#dialog").dialog("isOpen")) $("#dialog").dialog("close");
                        $("#dialog .dialogcontent").html(html);

                        $("#dialog").dialog({
                                title:title,
                                modal:false,
                                width:"auto",
                                height:"auto",
                                minWidth:400,
                                show:'fade',
                                buttons:{},
                                autoOpen:false,
                                //hide:'fade',
                                open: function(event, ui) {
                                        $(this).css({'max-height': 400, 'overflow-y': 'auto'});
                                }
                        });
                        $("#dialog").dialog('open');
                }
        });
}

